from tiles.tile import Tile, BlankTile
import pygame
import math

class Soil(Tile):
    def __init__(self, quality=0):
        super(Soil, self).__init__()
        self.playableTiles.append(BlankTile)
        self.__quality=quality
        
    def getQuality(self):
        return self.__quality
    
    def setQuality(self, quality):
        if quality < 0 : quality = 0
        if quality > 100 : quality = 100
        self.__quality = quality

    def showTile(self):
        srf = super(Soil, self).showTile()
        srf.fill(self.__getColor())
        return srf
    
    def __getColor(self): 
        rval = 100 - self.getQuality()
        gval = 50 - self.getQuality()
        bval = 0
        if rval > 255: rval = 255
        elif rval < 0: rval = 0
        if gval > 255: gval = 255
        elif gval <0: gval = 0
        if bval > 255: bval = 255
        elif bval < 0: bval = 0 
        
        color = pygame.Color(rval, gval, bval, 255)
        return color